package abstract_factory

import "fmt"

// 定义房门接口
type Door interface {
	Open()
}

// 安装师傅接口
type Installer interface {
	Install(door Door)
}
type WoodDoor struct{}

func (d *WoodDoor) Open() {
	fmt.Println("wood door open")
}

type IronDoor struct{}

func (d *IronDoor) Open() {
	fmt.Println("iron door open")
}

// 木匠
type Carpenter struct{}

func (o *Carpenter) Install(door Door) {
	fmt.Println("carpenter install door")
	door.Open()
}

// 焊工
type Welder struct {
}

func (o Welder) Install(door Door) {
	fmt.Println("welder install door")
	door.Open()
}

// 抽象工厂接口
type DoorFactory interface {
	CreateDoor() Door
	CreateInstaller() Installer
}

// 木门工厂
type WoodDoorFactory struct{}

func (o *WoodDoorFactory) CreateDoor() Door {
	return &WoodDoor{}
}
func (o *WoodDoorFactory) CreateInstaller() Installer {
	return &Carpenter{}
}

// 铁门工厂
type IronDoorFactory struct{}

func (o *IronDoorFactory) CreateDoor() Door {
	return &IronDoor{}
}
func (o *IronDoorFactory) CreateInstaller() Installer {
	return &Welder{}
}
